%{
/***************************************************************************
 *
 * $Id: lexer.l 25 2009-07-07 21:34:49Z Michael.McTernan $
 *
 * This file is part of tdgen, a timing diagram renderer.
 * Copyright (C) 2005 Michael C McTernan, Michael.McTernan.2001@cs.bris.ac.uk
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 **************************************************************************/


#include <stdint.h>
#include "tig.h"
#include "language.h"

/* Counter for error reporting */
unsigned long lex_linenum = 1;

%}

%option noyywrap nounput noinput

%x IN_COMMENT
%%

<IN_COMMENT>{
"*/"             BEGIN(INITIAL);
[^*\n]+
"*"
\r\n|\r|\n       lex_linenum++;
}


<INITIAL>{
"/*"             BEGIN(IN_COMMENT);

\r\n|\r|\n       lex_linenum++;

"\""[^\"\n]*"\"" yylval.string = yytext + 1; yytext[strlen(yytext) - 1] = '\0'; return TOK_STRING;
"{"              return TOK_OBRACE;
"}"              return TOK_CBRACE;
";"              return TOK_SEMICOLON;
"["              return TOK_OSBRACKET;
"]"              return TOK_CSBRACKET;
"="              return TOK_EQUAL;
","              return TOK_COMMA;
tdgen|timgen     return TOK_TIMG;

divs|DIVS        yylval.attr = TIG_GATTR_DIVS; return TOK_GATTR_DIVS;
url|URL          yylval.attr = TIG_ATTR_URL; return TOK_ATTR_URL;
colour|COLOUR    yylval.attr = TIG_ATTR_COLOUR; return TOK_ATTR_COLOUR;

"#"[^\n]*
"//"[^\n]*

[\r\f\n]+
[ \t]+

.             printf( "Unrecognized character: %s\n", yytext );
}

%%

/* END OF FILE */
